package zerous.craft;

import android.graphics.*;
import android.widget.*;

public class GameButton
{
	int x,y,w,h;
	Bitmap texture;
	public static boolean b;
	public GameButton(Bitmap b,int x,int y)
	{
		this.x = x;
		this.y = y;
		this.texture = b;
		w = b.getWidth();
		h = b.getHeight();
	}
	
	public void add(Canvas c,Paint p)
	{
		c.drawBitmap(texture,x,y,p);
		if(isTouch(x,y,w,h,MainActivity.Tx,MainActivity.Ty))
		{
			b = true;
		}
	}
	
	public boolean isTouch(int x1,int y1,int w1,int h1,int x2,int y2)
	{
		Rect r = new Rect(x1,y1,x1-w1,y1-h1);
		Region reg = new Region(r);
		return reg.contains(x2,y2);
	}
}
